package com.itheima;

import java.util.Random;
import java.util.Scanner;

public class Test6
{
    public static void main(String[] args) {
        //抽红包案例
        int[] moneys={10,20,30,40,50};
        start(moneys);
    }
    public static void start(int[] moneys){
        Scanner sc=new Scanner(System.in);
        Random r=new Random();

        for (int i = 0; i < 5; i++) {
            System.out.println("请输入任意数字抽取红包");
            sc.next();


            while (true) {
                int index=r.nextInt(moneys.length);
                int money=moneys[index];
                if(money!=0){
                    System.out.println("恭喜你，抽到了"+money+"元");
                    moneys[index]=0;
                    break;
                }
            }
        }
        System.out.println("红包已经抽完");

    }

}
